from django.db import models


# Create your models here.
# 创建地址类
class Area(models.Model):
    """省市区"""
    name = models.CharField(max_length=20, verbose_name='名称')
    parent = models.ForeignKey('self', on_delete=models.SET_NULL, related_name='subs', null=True, blank=True,
                               verbose_name='上级行政区划')
    # related_name 是指定外键关联的模型的名字
    # 默认是 关联模型类名小写_set -> area_set
    # 现在改为了 subs
    class Meta:
        db_table = 'areas'

    def __str__(self):
        return self.name
